<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>S&TV-KIDS</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi" />
<link href='http://fonts.googleapis.com/css?family=Raleway:200' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" href="/favicon.png" />
<link rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="framework/jquery-1.5.min.js"></script>
<script type="text/javascript" src="js/page_event.js"></script>
<script type="text/javascript" src="js/localstorage.js"></script>
<script type="text/javascript" src="js/spin.js"></script>
<script language="javascript">
<!--
	var json_url = "http://gdata.youtube.com/feeds/api/videos/";
	var $list;
	var total;
	var cnt = 0;
	var arrdn;
	
	$(document).ready(function()
	{
		
		arrdn = localDatabase('get', 'down_kidstube');
		
		if(arrdn)
		{
			total = arrdn.length;
			More();
		}
	});

	function More()
	{
		var response = "";
		
		$list = $("#list");

		$.getJSON(json_url + arrdn[cnt] + "?v=2&alt=jsonc", function(data)
		{	
			response = '<li>';
			response += '<a href="http://kidstube.kr/play.php?v=' + data.data.id + '">';
			response += '<dl>';
			response += '<dt>' + data.data.title + '</dt>';
			response += '<dd class="img_area" style="background:url(' + data.data.thumbnail.sqDefault + ') center center no-repeat">';
			response += '<span>' + time(data.data.duration) + '</span>';
			response += '</dd>';
			response += '<dd class="info_area">';
			response += '<strong>view</strong> <span>' + formatCurrency(data.data.viewCount) + "</span><br>";
			response += '<strong>like</strong> <span>' + formatCurrency(data.data.likeCount) + "</span>";
			response += '<span class="reply"> ' + formatCurrency(data.data.commentCount) + "</span>";
			response += '</dd>';
			response += '</dl>';
			response += '</a>';
			response += '<button type="button" onclick="javascript:Download(this);" id="' + data.data.id + '" class="btn_del on">delete</a>';
			response += '</li>';
			
		}).complete(function() 
		{
			$(response).appendTo($list);
			
			cnt++;
			
			if(cnt < total)
				More();
			else
				$("#list").show();
		});			
	}
		
	function Download(obj)
	{
		arrdn = localDatabase('get', 'down_kidstube');

		for(i=0; i<arrdn.length; i++)
		{
			if(arrdn[i] == obj.id)
			{
				arrdn.splice(i, 1);
				localDatabase('set', 'down_kidstube', arrdn);
			}
		}
		
		$(obj).parent().remove();			
		
		window.location.href = "http://kidstube.kr/delete.php?v=" + obj.id;
	}
	-->
</script>

<style>
	
</style>
</head>
<body id="download">
	<header>
		<h1>DOWNLOAD</h1>
		<div class="bg_animal"></div>
		<div class="bg_cloud"></div>
		<div class="bg_cloud2"></div>
		<div class="bg_cloud3"></div>
	</header>
	<div class="list_section">
		<ul class="list" id="list"></ul>
	</div>
</body>
</html>